#include "gamewidget.h"

gamewidget::gamewidget(QWidget *parent) : QWidget(parent)
{
    this->parent=parent;
    this->resize(1400,800);//大小要刚好和图片相等。
    //this->setWindowTitle("Please choose the level");//设置主窗口标题。
    this->setAutoFillBackground(true);//子窗体盖过父窗体；
    this->setWindowIcon(QIcon("C:/Users/jyh/Desktop/Fishing-files/fishing-files/img/Icon.png"));//设置窗口图标，图标的名字.png写在括号里。

   /*//设置背景颜色：
    QPalette palette;//定义一个调色板；
    palette.setColor(QPalette::Background,Qt::darkCyan);
    this->setPalette(palette);
    */

    //设置背景图片：
    QPalette palette;
    palette.setBrush(QPalette::Background,QBrush(QPixmap("C:/Users/jyh/Desktop/Fishing-files/fishing-files/img/Background.jpg")));
    this->setPalette(palette);

    //添加easy按钮；
    this->easybtn=new QPushButton(this);
    this->easybtn->setIcon(QIcon("C:/Users/jyh/Desktop/Fishing-files/fishing-files/img/easybtn"));
    this->easybtn->setIconSize(QSize(300,150));
    this->easybtn->setFlat(true);//去除底部白色边框；
    this->setFocusPolicy(Qt::NoFocus);

    //添加common按钮；
    this->commonbtn=new QPushButton(this);
    this->commonbtn->setIcon(QIcon("C:/Users/jyh/Desktop/Fishing-files/fishing-files/img/commonbtn"));
    this->commonbtn->setIconSize(QSize(300,150));
    this->commonbtn->setFlat(true);//去除底部白色边框；
    this->setFocusPolicy(Qt::NoFocus);

    //添加hard按钮
    this->hardbtn=new QPushButton(this);
    this->hardbtn->setIcon(QIcon("C:/Users/jyh/Desktop/Fishing-files/fishing-files/img/hardbtn"));
    this->hardbtn->setIconSize(QSize(300,150));
    this->hardbtn->setFlat(true);//去除底部白色边框；
    this->setFocusPolicy(Qt::NoFocus);

    //添加return按钮
    this->returnbtn=new QPushButton(this);
    this->returnbtn->setIcon(QIcon("C:/Users/jyh/Desktop/Fishing-files/fishing-files/img/returnbtn"));
    this->returnbtn->setIconSize(QSize(300,150));
    this->returnbtn->setFlat(true);//去除底部白色边框；
    this->setFocusPolicy(Qt::NoFocus);

    //布局：
    this->vboxlayout=new QVBoxLayout(this);
    this->vboxlayout->addWidget(easybtn);
    this->vboxlayout->addWidget(commonbtn);
    this->vboxlayout->addWidget(hardbtn);
    this->vboxlayout->addWidget(returnbtn);
    this->vboxlayout->setAlignment(Qt::AlignCenter);

    //信号与槽的关联：
    this->connect(returnbtn,SIGNAL(clicked()),this,SLOT(returnbtnclick()));
    this->connect(easybtn,SIGNAL(clicked()),this,SLOT(easybtnclick()));
    this->connect(commonbtn,SIGNAL(clicked()),this,SLOT(commonbtnclick()));
    this->connect(hardbtn,SIGNAL(clicked()),this,SLOT(hardbtnclick()));

}
void gamewidget::returnbtnclick()
{
    this->hide();
}
void gamewidget::easybtnclick()
{
    this->parent->hide();
    easyview=new Easyview;
    easyview->show();
}
void gamewidget::commonbtnclick()
{
    this->parent->hide();
    commonview=new Commonview;
    commonview->show();

}
void gamewidget::hardbtnclick()
{
    this->parent->hide();
    hardview=new Hardview;
    hardview->show();
}






